<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <style>
        /* .fade-enter{
            opacity: 0;
        }
        .fade-enter-active{
            transition: opacity 3s;
        }
        .fade-leave-to{
            opacity: 0;
        }
        .fade-leave-active{
            transition: opacity  3s;
        } */
        .fade-enter,.fade-leave-to{
            opacity: 0;
        }
        .fade-enter-active,.fade-leave-active{
            transition: opacity 3s;
        }
        

    </style>
</head>
<body>
    <div id="root">
        <!-- 在显示和隐藏的时候加上动画效果
            就在要动的标签外面包一个transation 标签
            当被transation包裹的元素
            就会需要'name'-enter和'name'-enter-active才能控制样式
            如果不写默认是V
            以上是显示动画
            以下是隐藏动画
            'name'-leave-to和'name'-leave-active
            可以应用v-show,v-if, 甚至还有动态组件
            用:is绑定组件名称的那个
        -->
        <transition name = 'fade'>
        <div v-if="show">hello world</div>
        </transition>
        
        <button @click="handleClick">切换</button>
    </div>

    <script>
        var vm  = new Vue({
            el:'#root',
            data:{
                show:true
            },
            methods:{
                handleClick(){
                    this.show = !this.show
                }
            }
        })
    </script>
</body>
</html>